#ifndef CUSTOM_SHADOWCASTER_PASS_INCLUDED
#define CUSTOM_SHADOWCASTER_PASS_INCLUDED

/*
#include "../ShaderLibrary/Common.hlsl"



TEXTURE2D(_BaseMap);
SAMPLER(sampler_BaseMap);

UNITY_INSTANCING_BUFFER_START(UnityPerMaterial)
	UNITY_DEFINE_INSTANCED_PROP(float4,_BaseColor)
	UNITY_DEFINE_INSTANCED_PROP(float4,_BaseMap_ST)
	UNITY_DEFINE_INSTANCED_PROP(float,_Cutoff)

UNITY_INSTANCING_BUFFER_END(UnityPerMaterial)
*/



struct Attributes 
{
	float3 positionOS : POSITION;
	float2 baseUV :TEXCOORD0;
	UNITY_VERTEX_INPUT_INSTANCE_ID
};

struct Varyings {
	float4 positionCS :SV_POSITION;
	float2 baseUV :VAR_BASE_UV;
	UNITY_VERTEX_INPUT_INSTANCE_ID
};

Varyings ShadowCasterPassVertex(Attributes input )
{
	Varyings output;
	UNITY_SETUP_INSTANCE_ID(input);
	UNITY_TRANSFER_INSTANCE_ID(input,output);

	float3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
	output.positionCS = TransformWorldToHClip(positionWS);

	/**/
	#if UNITY_REVERSED_Z
		output.positionCS.z = min(output.positionCS.z,output.positionCS.w * UNITY_NEAR_CLIP_VALUE);
	#else 
		output.positionCS.z = max(output.positionCS.z,output.positionCS.w * UNITY_NEAR_CLIP_VALUE);
	#endif
	
	/*
	float4 baseST = UNITY_ACCESS_INSTANCED_PROP(UnityPerMaterial,_BaseMap_ST);
	output.baseUV = input.baseUV * baseST.xy + baseST.zw;
	*/
	output.baseUV = TransformBaseUV(input.baseUV);
	return output;
}

void ShadowCasterPassFragment(Varyings input) 
{

	UNITY_SETUP_INSTANCE_ID(input);
	float4 baseColor =  UNITY_ACCESS_INSTANCED_PROP(UnityPerMaterial,_BaseColor);
	float4 baseMap = SAMPLE_TEXTURE2D(_BaseMap,sampler_BaseMap,input.baseUV);
	float4 base = baseColor * baseMap;
	#if defined(_SHADOWS_CLIP)
		//clip(base.a -  UNITY_ACCESS_INSTANCED_PROP(UnityPerMaterial,_Cutoff) );
		clip(base.a -  GetCutoff(input.baseUV) );
	#elif defined(_SHADOWS_DITHER)
		float dither = InterleavedGradientNoise(input.positionCS.xy,0);
		clip(base.a -  dither );
	#endif	
	//return base;
}

#endif